layui.define(function(e) {
	layui.use(["admin", "carousel"], function() {
		var e = layui.$,
			a = (layui.admin, layui.carousel),
			t = layui.element,
			i = layui.device();
		e(".layadmin-carousel").each(function() {
			var t = e(this);
			a.render({
				elem: this,
				width: "100%",
				arrow: "none",
				interval: t.data("interval"),
				autoplay: t.data("autoplay") === !0,
				trigger: i.ios || i.android ? "click" : "hover",
				anim: t.data("anim")
			})
		}), t.render("progress")
	}), layui.use(["carousel", "echarts"], function() {
		var e = layui.$,
			a = (layui.carousel, layui.echarts);
		initCharts = function(option, id,func) {
			var t = [],
				n = e("#" + id).children("div"),
				l = function(e) {
					t[e] = a.init(n[e], layui.echartsTheme), t[e].setOption(option[e]), window.onresize = t[e].resize;
					t[e].on('click', function (params) { 
						func(params)
					});
				};
			if(n[0]) {
				l(0);
			}
		}

		function clickObj(params){
			window.location.href='department_daily_detail.html';
		}
		
		initData_YS = function(options){
			
			// 医保自费合计
		var o_amount = [{
			tooltip: {
				trigger: 'axis'
			},
			calculable: true,
			legend: {
				data: options.legendName
			},
			xAxis: [{
				type: 'category',
				data: options.xAxisData
			}],
			yAxis: [{
					type: 'value',
					name: '总金额（元）',
					axisLabel: {
						formatter: '{value}'
					}
				},
				{
					type: 'value',
					name: '人数',
					axisLabel: {
						formatter: '{value}'
					}
				}
			],
			series: [
				{
					name: '总金额',
					type: 'bar',
					data: options.seriesData.counts
				},
				{
					name: '人均金额',
					type: 'bar',
					data: options.seriesData.averages
				},
				{
					name: '人数',
					type: 'line',
					yAxisIndex: 1,
					data: options.seriesData.peoples
				}
			]
		}]
		initCharts(o_amount, "medical-detail-YS",clickObj);
	
		}
		
		initData = function(){
			var options = {};
			options.seriesData = {};
			var legendName = [];
			legendName.push("总金额");
			legendName.push("人均金额");
			legendName.push("人数");
			options.legendName = legendName;
			options.xAxisData = ["医保初诊", "医保复诊", "医保合计", "自费初诊","自费复诊", "自费合计", "总计"];
			options.seriesData.counts = [42.8, 53.9, 86.3, 65.9,77.2, 38.5, 63.2];
			options.seriesData.averages = [42.8, 53.9, 86.3, 65.9,77.2, 38.5, 63.2];
			options.seriesData.peoples = [2, 3, 5, 6,5, 3, 2];
			initData_YS(options)
		}
		initData();
		
	}), e("department_daily_sub_2", {})
});